package com.jeasonzhao.commons.chart.model;

import java.util.Vector;

//One single line data, i.e. JeasonZhao 10,20,30,40
public class Series implements java.io.Serializable
{
    private static final long serialVersionUID = 1L;
    private String title = null;
    private java.util.Vector<Point> values = null;
    private RenderType renderType = RenderType.Unknown;
    private AxisType axis=AxisType.Primary;
    public Series()
    {
    }

    public Series(String strTitle)
    {
        this.title = strTitle;
    }

    public Series(RenderType render,String strTitle)
    {
        this.renderType = render;
        this.title = strTitle;
    }

    public Series(String strTitle,double ...values)
    {
        this.title = strTitle;
        this.addValue(values);
    }

    public Series(String strTitle,Point ...values)
    {
        this.title = strTitle;
        this.addValue(values);
    }

    public Series(RenderType render,String strTitle,double ...values)
    {
        this.renderType = render;
        this.title = strTitle;
        this.addValue(values);
    }

    public Series(RenderType render,String strTitle,Point ...values)
    {
        this.renderType = render;
        this.title = strTitle;
        this.addValue(values);
    }

    public Series addValue(Point ...pt)
    {
        if(null == pt)
        {
            return this;
        }
        if(null == this.values)
        {
            this.values = new Vector<Point>();
        }
        for(Point p : pt)
        {
            this.values.add(p);
        }
        return this;
    }

    public Series addValue(double ...pt)
    {
        if(null == pt)
        {
            return this;
        }
        if(null == this.values)
        {
            this.values = new Vector<Point>();
        }
        for(double p : pt)
        {
            this.values.add(new Point(p));
        }
        return this;
    }

    public int size()
    {
        return null != this.values ? this.values.size() : 0;
    }

    public String getTitle()
    {
        return title;
    }

    public Vector<Point> getValues()
    {
        return values;
    }

    public RenderType getRenderType()
    {
        return renderType;
    }

    public AxisType getAxis()
    {
        return axis;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public void setValues(Vector<Point> values)
    {
        this.values = values;
    }

    public void setRenderType(RenderType renderType)
    {
        this.renderType = renderType;
    }

    public void setAxis(AxisType axis)
    {
        this.axis = axis;
    }
}
